import json


def get_stored_username():
    """如果存储了用户名，就获取它"""
    filename = "username.json"
    try:
        with open(filename, encoding="utf-8") as f_obj:
            username = json.load(f_obj)
    except FileNotFoundError:
        return None
    else:
        return username


def get_new_username():
     """提示用户输入用户名"""
     username = input("你的名字是什么？")
     filename = "username.json"
     with open(filename, 'w') as f_obj:
         json.dump(username, f_obj)
     return username

def greet_user():
    """问候用户，并指出名字"""
    username = get_stored_username()
    if username:
        print("欢迎回来" + username)
    else:
        username = get_new_username()
        print("我们会记住你的" + username)
greet_user()